﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using SharingCenter.Web.Classes.Favorites;

namespace SharingCenter.Web.Mod.Favorite
{
    /// <summary>
    /// Summary description for FavoriteServices
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class FavoriteServices : System.Web.Services.WebService
    {

        [WebMethod]
        [ScriptMethod]
        public bool AddFavorite(string contextName, string contextId, string userId, string comment)
        {
            try
            {
                Guid cid = new Guid(contextId);
                Guid uid = new Guid(userId);
                FavoriteOperations.AddFavorite(contextName, cid, uid, comment);
                return true;
            }
            catch { return false; }
        }

        [WebMethod]
        [ScriptMethod]
        public bool DeleteFavorite(string contextName, string contextId, string userId)
        {
            try
            {
                Guid cid = new Guid(contextId);
                Guid uid = new Guid(userId);
                return FavoriteOperations.DeleteFavorite(contextName, cid, uid);
            }
            catch { return false; }
        }
    }
}
